#!/bin/bash

#Created by turk 2015-11-30
#Delete Hbase Region & Meta 
#Version 1.0 



if [ $# -lt 2 ]; then
	echo `date +"%Y-%m-%d %H:%M:%S"`  "Usage:<TABLENAME> <FILE>"
	exit 1
fi

TABLENAME=$1
FILE=$2

WORKPATH=/home/hadoop/turk/
JAVALIB=${WORKPATH}/lib/
LOGFILE=${WORKPATH}/log/hbase_export_sh.log


echo `date +"%Y-%m-%d %H:%M:%S"`  "-------------------------------------------" | tee -a $LOGFILE
echo `date +"%Y-%m-%d %H:%M:%S"`  "Delete Hbase Region & Meta 1.0 (2015-11-30)"     | tee -a $LOGFILE
echo `date +"%Y-%m-%d %H:%M:%S"`  "Delete"  | tee -a $LOGFILE
echo `date +"%Y-%m-%d %H:%M:%S"`  "-------------------------------------------"  | tee -a $LOGFILE
echo `date +"%Y-%m-%d %H:%M:%S"`  "Start..."  | tee -a $LOGFILE





cat $FILE | while read line 
do
#        echo "$line"
regionpath=/hbase/data/default/$1/`echo "$line" | awk -F ',' '{print $3}' | awk -F '.' '{print $2}'`
TABLENAME=`echo "$line" | awk -F ',' '{print $1}'`
echo "$regionpath"
echo "$line" 
hadoop fs -mv  $regionpath /tmp/hbase/delete
echo "deleteall 'hbase:meta','$line'" | hbase shell
done < $2


exit 0
